$('#type').click(function(){
        $(this).change(function(){
            var objectModel = {};
            var   value = $(this).val();
            var   type = $(this).attr('id');
            objectModel[type] =value;
            $.ajax({
                cache:false,
                type:"POST",
                url:"/hongdi/db_carorder_system/tp/index.php/Html/Order/oil",
                dataType:"json",
                data:objectModel,
                timeout:30000,
                error:function(){
                    alert("lable");
                },
                success:function(data){
                    $("#lables").empty();
                    var count = data.length;
                    var i = 0;
                    var b="";
                    for(i=0;i<count;i++){
                        b+="<option value='"+data[i].father_id+"' >"+data[i].name+"</option>";
                    }
                    var c="<option>请选择</option>";
                    $("#lables").append(c);
                    $("#lables").append(b);
                }
            });
        });
    }
);
$(".subBtn").click(function () {
    var name=$('input[name="name"]').val();
    var phone=$('input[name="phone"]').val();
    var oilFather=$('select#type').find("option:selected").text();
    var oil=$('select#lables').find("option:selected").text();
    var plateNumber=$('input[name="plateNumber"]').val();
    var company=$('input[name="company"]').val();
    var plateNumberFirst=$('select#first').find("option:selected").text();
    var plateNumberSecond=$('select#second').find("option:selected").text();
    if(!name) {
        dialog.error("真实姓名不能为空");
    }
    else if(!phone) {
        dialog.error("联系电话不能为空");
    }
    else if(!oil) {
        dialog.error("油品类型不能为空");
    }
    else if(!oilFather){
        dialog.error("油品类型不能为空");
    }
    else if(!plateNumber){
        dialog.error("车牌号不能为空");
    }
    else if(!company){
        dialog.error("公司名不能为空");
    }
    else{
        var url = "/hongdi/db_carorder_system/tp/index.php/HTML/Order/addOrder";
        var data = {'name':name,'phone':phone,'oilFather':oilFather,'oil':oil,'car_plate_number':plateNumber,'company':company,'first':plateNumberFirst,'second':plateNumberSecond};
        // 执行异步请求  $.post
        $.post(url,data,function(result){
            if(result.status == 0) {
                return dialog.error(result.message);
                console.log("error")
            }
            if(result.status == 1) {
                return dialog.success(result.message, '/hongdi/db_carorder_system/tp/index.php/HTML/Order/index');
                console.log("succes")
            }
        },'JSON');
    }

});